IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].FindMatchingAttachmentName') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].FindMatchingAttachmentName
GO

/***************************************************************************
* Name:				FindMatchingAttachmentName
* Purpose:			Finds any exsisting attachment with the same passed parameters 
*
* PARAMETERS
* Name				Description					
* -------------		-----------------------------------------------------------
* @attachmentName	name of the attachment
* @attachmentType	type of the attachment
***************************************************************************/

CREATE PROCEDURE dbo.FindMatchingAttachmentName
(
	@protocolId		INT,
	@attachmentName VARCHAR(255),
	@attachmentType VARCHAR(50)
)
AS
BEGIN
	
	SET NOCOUNT ON

	select 1 
	from ProtocolDocument
	where Name = @attachmentName
	and Type = @attachmentType
	and ProtocolId = @protocolId

END

GO

